package org.example.bean4;



import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan   //如果扫描的是自身包及子包，则可以省略basePackages
public class App7 {
    public static void main(String[] args) {
        ApplicationContext ac = new AnnotationConfigApplicationContext(App7.class);
        //我想测试  Student是singleton, 还是 prototype
        Student s1 = ac.getBean(Student.class);
        Student s2 = ac.getBean(Student.class);
//        System.out.println(s1.hashCode() );
//        System.out.println(s2.hashCode() );
//        System.out.println( s1== s2 );

    }
}

//  singleton  单例的   一个实例， 构造方法只调用一次    是spring容器初始化时.
//  prototype   多例的,          构造方法调用多次.    不是spring容器初始化时调用的.
// 构造方法是在getBean()调用.   -> 懒加载.
